﻿Imports System.Text.RegularExpressions

Public Class Form1

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        'cmbBoxAno.DropDownStyle = 2
        cmbBoxAno.Text = "Año"
        'cmbBoxMes.DropDownStyle = 2
        cmbBoxMes.Text = "Mes"
        'cmbBoxDia.DropDownStyle = 2
        cmbBoxDia.Text = "Día"
        'cmbBoxEstado.DropDownStyle = 2
        cmbBoxEstado.Text = "Estado de México"
        'cmbBoxFormaPago.DropDownStyle = 2
        cmbBoxFormaPago.Text = "Forma de Pago"
        'CmbBoxInicio.DropDownStyle = 2
        CmbBoxInicio.Text = "Inicio de Clases"
        'cmbBoxTipoCurso.DropDownStyle = 2
        cmbBoxTipoCurso.Text = "Tipo de Curso"
        'cmbBoxMes.DropDownStyle = 2
        'cmbBoxEnterado.DropDownStyle = 2
        cmbBoxEnterado.Text = "Como se entero de nosotros?"


    End Sub
    Private Sub borrar()
        txtApellM.Clear()
        txtApellM.BackColor = Color.White
        txtApellP.Clear()
        txtApellP.BackColor = Color.White
        txtCel.Clear()
        txtCel.BackColor = Color.White
        txtDireccion.Clear()
        txtDireccion.BackColor = Color.White
        txtCP.Clear()
        txtCP.BackColor = Color.White
        txtNombre.Clear()
        txtNombre.BackColor = Color.White
        txtTel.Clear()
        txtTel.BackColor = Color.White
        txtEmail.Text = "NA"
        txtEmail.BackColor = Color.White
        txtInscripcion.Text = "750"
        txt1Pago.Text = "1500"
        txt2Pago.Text = "1500"
        txtMun.Text = "Ecatepec"
        txtMun.BackColor = Color.White
        cmbBoxEstado.Text = "Estado de Mexico"
        CmbBoxInicio.Text = "Inicio de Clases"
        cmbBoxEnterado.Text = "Como se entero de nosotros?"
        cmbBoxAno.Text = "Año"
        cmbBoxDia.Text = "Dia"
        cmbBoxFormaPago.Text = "Forma de Pago"
        cmbBoxMes.Text = "Mes"
        cmbBoxTipoCurso.Text = "Tipo de Curso"
        radBtnNoBeca.Checked = True
        radBtnBeca.Checked = False
        txtEnterado.Visible = False
        txtEnterado.Text = "Especifica"
    End Sub

    Private Sub btnIns_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnIns.Click
        groupBoxInsc1.Visible = True
        groupBoxInsc2.Visible = False
        groupBoxInsc3.Visible = False
        ''UnderConstuction.Visible = False = False

    End Sub

    Private Sub btnPag_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPag.Click
        groupBoxInsc1.Visible = False
        groupBoxInsc3.Visible = False
        groupBoxInsc2.Visible = False
        'UnderConstuction.Visible = False = True
    End Sub

    Private Sub btnUsu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUsu.Click
        groupBoxInsc1.Visible = False
        groupBoxInsc2.Visible = False
        groupBoxInsc3.Visible = False
        'UnderConstuction.Visible = False = True
    End Sub

    Private Sub btnAlu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAlu.Click
        groupBoxInsc1.Visible = False
        groupBoxInsc2.Visible = False
        groupBoxInsc3.Visible = False
        'UnderConstuction.Visible = False = True
    End Sub

    Private Sub btnBus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBus.Click
        groupBoxInsc1.Visible = False
        groupBoxInsc2.Visible = False
        groupBoxInsc3.Visible = False
        'UnderConstuction.Visible = False = True
    End Sub


    Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radBtnBeca.CheckedChanged
        txt1Pago.ReadOnly = False
        txt1Pago.Text = 1500
        txt2Pago.ReadOnly = False
        txt2Pago.Text = 1500
        txtInscripcion.ReadOnly = False
        txtInscripcion.Text = 750
    End Sub

    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radBtnNoBeca.CheckedChanged
        txt1Pago.ReadOnly = True
        txt2Pago.ReadOnly = True
        txtInscripcion.ReadOnly = True
    End Sub

    Private Sub btnSalir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSalir.Click
        End
    End Sub


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLimpiar.Click
        borrar()
    End Sub
    Private Sub cmbBoxEnterado_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbBoxEnterado.SelectedIndexChanged
        If (cmbBoxEnterado.Text.StartsWith("Otra")) Then
            txtEnterado.Visible = True
        Else
            txtEnterado.Visible = False
        End If

    End Sub

    Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
        If (valida()) Then
            groupBoxInsc1.Visible = False
            groupBoxInsc2.Visible = True
        Else
            MessageBox.Show("Los datos no son correctos", "Error", MessageBoxButtons.OK)
        End If

    End Sub

    Private Sub groupInsc2_VisibleChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles groupBoxInsc2.VisibleChanged
        txtNombre1.Text = txtNombre.Text + " " + txtApellP.Text + " " + txtApellM.Text
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        groupBoxInsc1.Visible = True
        groupBoxInsc2.Visible = False
    End Sub


    Public Function calculaBeca() As Integer
        Dim saldo = New Integer
        saldo = Val(txt1Pago.Text) + Val(txt2Pago.Text) + Val(txtInscripcion.Text)
        Return 100 - saldo * 100 / 3750
    End Function
    Private Sub groupBoxInsc3_VisibleChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles groupBoxInsc3.VisibleChanged
        txtNom1.Text = txtNombre1.Text
        txtFecha1.Text = cmbBoxDia.Text + " de " + cmbBoxMes.Text + " de " + cmbBoxAno.Text
        txtDireccion1.Text = txtDireccion.Text + " CP: " + txtCP.Text + vbCrLf + txtMun.Text + ", " + cmbBoxEstado.Text
        txtCel1.Text = txtCel.Text
        txtTel1.Text = txtTel.Text
        txtEmail1.Text = txtEmail.Text
        txtCurso.Text = cmbBoxTipoCurso.Text
        If (radBtnBeca.Checked) Then
            txtBeca1.Text = "El alumno cuenta con una beca del " & calculaBeca() & "%."
        Else
            txtBeca1.Text = "El alumno no tiene beca"
        End If
        If btnMasculino.Checked Then
            txtSexo.Text = "Masculino"
        Else
            txtSexo.Text = "Femenino"

        End If
        txtPago10.Text = "El primer pago debera de realizarse antes del 1ro de " + CmbBoxInicio.Text
    End Sub

    Private Sub btnGuardar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGuardar.Click
        groupBoxInsc3.Visible = True
        groupBoxInsc2.Visible = False

    End Sub

    Private Sub btnEditar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEditar.Click
        groupBoxInsc3.Visible = False
        groupBoxInsc1.Visible = True
    End Sub

    Private Function valida() As Boolean
        If (txtNombre.BackColor.Equals(Color.White) Or txtApellM.BackColor.Equals(Color.White) Or txtApellP.BackColor.Equals(Color.White) Or txtCel.BackColor.Equals(Color.White) Or txtTel.BackColor.Equals(Color.White) Or txtDireccion.BackColor.Equals(Color.White) Or txtEmail.BackColor.Equals(Color.White) Or txtMun.BackColor.Equals(Color.White)) Then
            Return False
        Else
            Return True
        End If
    End Function

    Private Sub btnAceptar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAceptar.Click
        MessageBox.Show("Guardado con exito", "Guardar", MessageBoxButtons.OK)
        groupBoxInsc3.Visible = False
        groupBoxInsc1.Visible = True
        borrar()


    End Sub

    'Private Sub cmbBoxEstado_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles cmbBoxEstado.KeyPress
    '    Static sFindString As String = ""
    '    Static HoldForFewSecs As DateTime = "1/1/0001 12:00:00 AM"

    '    If HoldForFewSecs = "1/1/0001 12:00:00 AM" Then HoldForFewSecs =
    '    Now.AddMilliseconds(1200)

    '    Dim index As Integer
    '    If Now < HoldForFewSecs Then
    '        sFindString &= e.KeyChar.ToString
    '        index = Me.cmbBoxEstado.FindString(sFindString)
    '        cmbBoxEstado.SelectedIndex = index
    '    Else
    '        sFindString = e.KeyChar.ToString
    '        index = Me.cmbBoxEstado.FindString(sFindString)
    '        cmbBoxEstado.SelectedIndex = index
    '        HoldForFewSecs = "1/1/0001 12:00:00 AM"
    '    End If
    'End Sub

    'Private Sub cmbBoxDia_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles cmbBoxDia.KeyPress
    '    Static sFindString As String = ""
    '    Static HoldForFewSecs As DateTime = "1/1/0001 12:00:00 AM"

    '    If HoldForFewSecs = "1/1/0001 12:00:00 AM" Then HoldForFewSecs =
    '    Now.AddMilliseconds(1200)

    '    Dim index As Integer
    '    If Now < HoldForFewSecs Then
    '        sFindString &= e.KeyChar.ToString
    '        index = Me.cmbBoxDia.FindString(sFindString)
    '        cmbBoxDia.SelectedIndex = index
    '    Else
    '        sFindString = e.KeyChar.ToString
    '        index = Me.cmbBoxDia.FindString(sFindString)
    '        cmbBoxDia.SelectedIndex = index
    '        HoldForFewSecs = "1/1/0001 12:00:00 AM"
    '    End If
    'End Sub

    'Private Sub cmbBoxMes_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles cmbBoxMes.KeyPress
    '    Static sFindString As String = ""
    '    Static HoldForFewSecs As DateTime = "1/1/0001 12:00:00 AM"

    '    If HoldForFewSecs = "1/1/0001 12:00:00 AM" Then HoldForFewSecs =
    '    Now.AddMilliseconds(1200)

    '    Dim index As Integer
    '    If Now < HoldForFewSecs Then
    '        sFindString &= e.KeyChar.ToString
    '        index = Me.cmbBoxMes.FindString(sFindString)
    '        cmbBoxMes.SelectedIndex = index
    '    Else
    '        sFindString = e.KeyChar.ToString
    '        index = Me.cmbBoxMes.FindString(sFindString)
    '        cmbBoxMes.SelectedIndex = index
    '        HoldForFewSecs = "1/1/0001 12:00:00 AM"
    '    End If
    'End Sub

    'Private Sub cmbBoxAno_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles cmbBoxAno.KeyPress
    '    Static sFindString As String = ""
    '    Static HoldForFewSecs As DateTime = "1/1/0001 12:00:00 AM"

    '    If HoldForFewSecs = "1/1/0001 12:00:00 AM" Then HoldForFewSecs =
    '    Now.AddMilliseconds(1200)

    '    Dim index As Integer
    '    If Now < HoldForFewSecs Then
    '        sFindString &= e.KeyChar.ToString
    '        index = Me.cmbBoxAno.FindString(sFindString)
    '        cmbBoxAno.SelectedIndex = index
    '    Else
    '        sFindString = e.KeyChar.ToString
    '        index = Me.cmbBoxAno.FindString(sFindString)
    '        cmbBoxAno.SelectedIndex = index
    '        HoldForFewSecs = "1/1/0001 12:00:00 AM"
    '    End If
    'End Sub

    Private Sub txtNombre_LostFocus(sender As Object, e As System.EventArgs) Handles txtNombre.LostFocus
        If (txtNombre.Text.Equals("")) Then
            txtNombre.BackColor = Color.LightCoral
        Else
            txtNombre.BackColor = Color.LightGreen
        End If
    End Sub

    Private Sub txtApellP_LostFocus(sender As Object, e As System.EventArgs) Handles txtApellP.LostFocus
        If (txtApellP.Text.Equals("")) Then
            txtApellP.BackColor = Color.LightCoral
        Else
            txtApellP.BackColor = Color.LightGreen
        End If
    End Sub

    Private Sub txtApellM_LostFocus(sender As Object, e As System.EventArgs) Handles txtApellM.LostFocus
        If (txtApellM.Text.Equals("")) Then
            txtApellM.BackColor = Color.LightCoral
        Else
            txtApellM.BackColor = Color.LightGreen
        End If
    End Sub

    Private Sub txtDireccion_LostFocus(sender As Object, e As System.EventArgs) Handles txtDireccion.LostFocus
        If (txtDireccion.Text.Equals("")) Then
            txtDireccion.BackColor = Color.LightCoral
        Else
            txtDireccion.BackColor = Color.LightGreen
        End If
    End Sub

    Private Sub txtMun_LostFocus(sender As Object, e As System.EventArgs) Handles txtMun.LostFocus
        If (txtMun.Text.Equals("")) Then
            txtMun.BackColor = Color.LightCoral
        Else
            txtMun.BackColor = Color.LightGreen
        End If
    End Sub
    Private Sub txtTel_LostFocus(sender As Object, e As System.EventArgs) Handles txtTel.LostFocus
        If (IsNumeric(txtTel.Text)) Then
            txtTel.BackColor = Color.LightGreen
        Else
            txtTel.BackColor = Color.LightCoral
        End If
    End Sub

    Private Sub txtCel_LostFocus(sender As Object, e As System.EventArgs) Handles txtCel.LostFocus
        If (IsNumeric(txtCel.Text)) Then
            txtCel.BackColor = Color.LightGreen
        Else
            txtCel.BackColor = Color.LightCoral
        End If
    End Sub

    Private Sub txtEmail_LostFocus(sender As Object, e As System.EventArgs) Handles txtEmail.LostFocus
        If (txtEmail.Text.Equals("")) Then
            txtEmail.Text = "NA"
        End If
        If (Regex.IsMatch(txtEmail.Text, "[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z_+])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9}$") Or txtEmail.Text.Equals("NA")) Then
            txtEmail.BackColor = Color.LightGreen
        Else
            txtEmail.BackColor = Color.LightCoral
        End If
    End Sub

    Private Sub txtCP_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles txtCP.KeyPress
        If (Microsoft.VisualBasic.Asc(e.KeyChar) < 48) _
       Or (Microsoft.VisualBasic.Asc(e.KeyChar) > 57) Then
            e.Handled = True
        End If

        If (Microsoft.VisualBasic.Asc(e.KeyChar) = 46 Or Microsoft.VisualBasic.Asc(e.KeyChar) = 8 Or Microsoft.VisualBasic.Asc(e.KeyChar) = 45) Then
            e.Handled = False
        End If
    End Sub

    Private Sub txtCP_LostFocus(sender As Object, e As System.EventArgs) Handles txtCP.LostFocus
        If (txtCP.TextLength = 5) Then
            txtCP.BackColor = Color.LightGreen
        Else
            txtCP.BackColor = Color.LightCoral
        End If
    End Sub

    Private Sub txtNombre_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtNombre.TextChanged

    End Sub
End Class
